package com.egene.tw.api;


import com.egene.tw.model.User;
import com.egene.tw.network.ApiConstant;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;

import static com.egene.tw.network.ApiHttpClient.post;

/**
 * 
 * @author WZX create by 2015/5/18
 */
public class LoginApi{
	public final static String API_URL = ApiConstant.API_URL;

	/**
	 * 注册
	 * @param handler
	 */
	public static void register(User user, String vCode, AsyncHttpResponseHandler handler) {
		RequestParams params = new RequestParams();
		params.put("cmd", "ServerHandler.RegUser");
		params.put("loginid", user.getLoginID());
		params.put("password", user.getPassword());
		params.put("mobile", user.getMobile());
		params.put("vcode", vCode);
		params.put("username", user.getUserName());
		params.put("sex", user.getSex());
		params.put("birthday", user.getBirthday());
		params.put("height", user.getHeight());
		params.put("weight", user.getWeight());
		post(API_URL, params, handler);
	}


	/**
	 * 获取验证码
	 * @param phone
	 * @param loginId
	 * @param handler
	 */
	public static void getVCode(String phone, String loginId, AsyncHttpResponseHandler handler){
		RequestParams params = new RequestParams();
		params.put("cmd", "ServerHandler.GetSMSVCode");
		params.put("mobile", phone);
		params.put("loginid", loginId);
		post(API_URL, params, handler);
	}

	/**
	 * 登录
	 * @param loginid
	 * @param password
	 * @param handler
	 */
	public static void login(String loginid, String password,String clientId, AsyncHttpResponseHandler handler){
		RequestParams params = new RequestParams();
		params.put("cmd", "ServerHandler.UserLogin");
		params.put("loginid", loginid);
		params.put("password", password);
		params.put("clientid", clientId);
		post(API_URL, params, handler);

	}

	/**
	 * 修改手机
	 */
	public static void changePhone(String userId, String oldMobile, String newMobile, String vCode, AsyncHttpResponseHandler handler) {
		RequestParams params = new RequestParams();
		params.put("cmd", "ServerHandler.ModifyMobile");
		params.put("userId", userId);
		params.put("oldmobile", oldMobile);
		params.put("newmobile", newMobile);
		params.put("vcode", vCode);
		post(API_URL, params, handler);
	}

	/**
	 * 修改手机
	 */
	public static void updateGetuiClient(String userId, String clientid, AsyncHttpResponseHandler handler) {
		RequestParams params = new RequestParams();
		params.put("cmd", "ServerHandler.GeTuiClientID");
		params.put("userId", userId);
		params.put("clientid", clientid);
		post(API_URL, params, handler);
	}
}
